package cn.itcast.demo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Demo1 {
    public static void main(String[] args) throws Exception {
//        1.注册驱动
       Class.forName("com.mysql.jdbc.Driver");
//       2.获取链接
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/db5", "root", "");
//        3.获取执行者对象
        Statement statement = connection.createStatement();
//        4.执行sql语句
        String sql = "select * from t_nump";
        ResultSet resultSet = statement.executeQuery(sql);
//        5.处理结果
        while(resultSet.next()){
            System.out.println(resultSet.getInt("id") + "   " + resultSet.getString("uid") + "  " + resultSet.getString("password"));
        }
//        释放资源
        connection.close();
        statement.close();
        resultSet.close();

    }

}
